<%--
  Created by IntelliJ IDEA.
  User: fyf
  Date: 2018/11/12
  Time: 9:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
  session.getAttribute("branchid");
  session.getAttribute("branchName");
%>
<html>
<head>
  <title>添加班级信息</title>

  <jsp:include page="/common/basecss.jsp" flush="true"/>
  <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.js"></script>
  <script src="${pageContext.request.contextPath}/assets/js/layer-v3.1.0/layer/layer.js"></script>
</head>
<body>


<form action="${pageContext.request.contextPath}/admin/manager/addTclass.go"
      id="classForm" class="form-horizontal" method="post">

  <h5 class="page-header alert-info" style="padding:10px; margin:0px; margin-bottom:5px;">班级信息</h5>
  <div class="row">
    <div class="col-sm-5">
      <div class="form-group">
        <label class="col-sm-3 control-label">班级id</label>
        <div class="col-sm-6">
          <input type="text" name="id" readonly="readonly" class="form-control input-sm" placeholder="后台生成班级编号"/>
        </div>
      </div>

    </div>
    <div class="col-sm-5">
      <div class="form-group">
        <label class="col-sm-3 control-label">班级名称</label>
        <div class="col-sm-6">
          <input type="text" name="classname" id="classname" class="form-control input-sm" placeholder="请输入班级名称"/>
        </div>
      </div>
    </div>

  </div>
  <%--分公司id--%>
  <input type="hidden" name="branchid" id="branchid"   value="${branchid}">

  <div class="row">
    <div class="col-sm-6 col-sm-offset-3">
      <input  type="button" id="submitButton" class="btn btn-success" value="添加"/>

    </div>
  </div>
</form>

<script>
  $(function () {
      /*ajax提交，成功之后父级页面刷新*/
      /*$("#submitButton").click(function () {
          $("#classForm").submit();
          layer.load(1,{shade: false});
          setTimeout(function () {
              parent.location.reload();
          }, 2000);

      });*/
      $("#submitButton").click(function () {

          var classname = $('#classname').val();
          var branchId= $('#branchid').val();
          $.ajax({
              type:'post',
              url:'addTclass.go',
              data:{"classname":classname,"branchId":branchId},
              dataType:'json',
              success:function (resData) {
                  if (resData!=null&&resData.classname!=""&&resData.classname!=null){
                      layer.msg('班级添加成功',{icon: 1});
                      setTimeout(function () {
                          parent.location.reload();
                      },1000);

                  } else if(resData.classname=null||resData.classname==""){
                      layer.msg('请填写班级名称',{icon: 4});
                  }else {
                      layer.msg('添加失败',{icon: 2});
                  }
              },
              error:function () {

              }
          });
      });




  });


</script>




<jsp:include page="/common/basejs.jsp" flush="true"/>
</body>
</html>
